/*
 * @Author: szx
 * @Date: 2022-01-15 12:42:41
 * @LastEditTime: 2022-01-15 12:51:31
 * @Description: 
 * @FilePath: \leetcode\300-399\377\377.js
 */
/**
 * @param {number[]} nums
 * @param {number} target
 * @return {number}
 */
var combinationSum4 = function (nums, target) {
    const n = nums.length;
    const dp = new Array(target + 1).fill(0);
    dp[0] = 1;
    for (let i = 0; i <= target; i++) {
        for (let j = 0; j < n; j++) {
            if (i < nums[j]) continue;
            dp[i] += dp[i - nums[j]]
        }
    }
    return dp[target]
};